﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;

public partial class ProductArchives_ExpressCompany : System.Web.UI.Page
{
    protected void Page_PreInit(object sender, EventArgs e)
    {
        Page.Theme = BLL.Common.GetWSMThemes();
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        Check.CheckPermission("200600103");
        if (!IsPostBack)
        {
            AspNetPager1.PageSize = Convert.ToInt32(ConfigurationManager.AppSettings["RowCountPerPage"].ToString());
            SearchControl1.InitParam("TRANER", "TRANER_CODE", "TRANER_NAME", "TRANERListControl1", "rptTRANER", "AspNetPager1");
            Bind();
        }
    }
    private void Bind()
    {
        int pageCount, rowCount;
        List<Model.TRANER> companies = new BLL.TRANER().GetList(AspNetPager1.PageSize, AspNetPager1.CurrentPageIndex, "TRANER_CODE", false, "", out pageCount, out rowCount);
        TRANERListControl1.Bind(companies);
        AspNetPager1.RecordCount = rowCount;
    }
    protected void AspNetPager1_PageChanged(object sender, EventArgs e)
    {
        int pageCount, rowCount;
        if (SearchControl1.IsSearchResult)
        {
            Repeater rpt = (Repeater)TRANERListControl1.FindControl("rptTRANER");
            if (rpt != null)
            {
                string strSql;
                SearchControl1.BindParentPageControl(rpt, AspNetPager1, SearchControl1.DataTableName, SearchControl1.PrimaryKeyColumnName, SearchControl1.StrCondition, AspNetPager1.PageSize, AspNetPager1.CurrentPageIndex, out pageCount, out rowCount, out strSql);
            }
        }
        else
        {
            List<Model.TRANER> companies = new BLL.TRANER().GetList(AspNetPager1.PageSize, AspNetPager1.CurrentPageIndex, "TRANER_CODE", false, "", out pageCount, out rowCount);
            TRANERListControl1.Bind(companies);
        }
    }
    public void Add()
    {
        if (Check.CheckPermission("200600103", "00001"))
        {
            Response.Redirect("ExpressCompanyEdit.aspx");
        }
        else
        {
            Share.Alert(this.Page,"无权操作"); return;
        }
    }
    public void Update()
    {
        if (Check.CheckPermission("200600103", "00002"))
        {
            List<string> s = TRANERListControl1.Selected;
            if (s.Count > 0)
            {
                Response.Redirect("ExpressCompanyEdit.aspx?code=" + s[0]);
            }
            else
            {
                //MessageBox.Show("s");
                Page.RegisterStartupScript("StartUp", "<script language=javascript>alert('请选择一条需要编辑的记录')</script>");
                //Share.Alert(this.Page,"请选择操作行"); 
            }
        }
        else
        {
            Share.Alert(this.Page,"无权操作"); return;
        }
    }
    public void Delete()
    {
        if (Check.CheckPermission("200600103", "00003"))
        {
            List<string> s = TRANERListControl1.Selected;
            new BLL.TRANER().Delete(s);
            Share.InsertLog("200600103", "00003");
            Response.Redirect("ExpressCompany.aspx");
        }
        else
        {
            Share.Alert(this.Page,"无权操作"); return;
        }
    }
}
